package com.listeningframework.boot.commons.math;

/**
 * 
 * CommonNumberUtils
 *
 * @author listening
 * @version $Id: CommonNumberUtils.java, v 0.1 2015年11月1日 下午11:28:26 listening Exp $
 */
public class NumberUtils extends org.apache.commons.lang3.math.NumberUtils {

    /**
     * Convert Long To Int
     *
     * @param value Long
     * @return Integer
     */
    public static final Integer longToInt(Long value) {
        if (value > Integer.MAX_VALUE || value < Integer.MIN_VALUE) {
            throw new RuntimeException("long value overflow integer area");
        }
        return toInt(String.valueOf(value), 0);
    }

    /**
     * Less Equal Than CompareValue
     *
     * @param value Inteter
     * @param compareVal Inteter
     * @return boolean
     */
    public static final boolean let(Integer value, Integer compareVal) {
        if (value == null && compareVal == null) {
            return true;
        }
        if (value == null || compareVal == null) {
            return false;
        }
        return value <= compareVal;
    }

    /**
     * Is Blank Or Zero
     *
     * @param value 值
     * @return boolean
     */
    public static final boolean isBlankZero(Integer value) {
        return value == null || value == 0;
    }
}
